package com.souku.finance.application.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

import com.souku.finance.application.R;

/**
 * Created by Android on 2016/11/21.
 */

public class BackgroundRelativeLayout extends RelativeLayout {

    public BackgroundRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BackgroundRelativeLayout(Context context) {
        super(context);
    }

    public BackgroundRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            setBackgroundColor(getResources().getColor(R.color.gray_background));
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            setBackgroundColor(getResources().getColor(R.color.white));
        }
        return super.onTouchEvent(event);
    }
}
